<template>
  <div class="login-container">
    <div class="login-board">
      <div class="images"></div>
      <div class="login-form">
        <div class="login-switch" @click="changeLoginType">
          <div class="list">
            <img
              src="@/assets/config/login-qrcode@2x.png"
              alt=""
              v-if="state.loginType === 1"
            />
            <img src="@/assets/config/login-pswd@2x.png" alt="" v-else />
          </div>
        </div>
        <div class="title">文档管理平台</div>
        <component :is="componentsMaps[state.loginType]"></component>
      </div>
    </div>
    <footer>福建左海科技有限公司</footer>
  </div>
</template>

<script setup lang="ts">
import { reactive } from "vue"
import AccountLogin from "./account-login.vue"
import DingdingLogin from "./dingding-login.vue"

interface componentsMaps {
  [key: number]: any
}
const componentsMaps: componentsMaps = {
  1: AccountLogin,
  2: DingdingLogin,
}
const state = reactive({
  loginType: 1, //1 账号密码登陆 2钉钉登陆
})

function changeLoginType() {
  state.loginType = state.loginType === 1 ? 2 : 1
}
</script>

<style lang="scss">
.login-container {
  background-image: url("@/assets/config/bg.png");
  background-size: 100% 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;

  .login-board {
    position: relative;
    z-index: 10;
    width: 700px;
    height: 394px;
    box-shadow: 0px 12px 21px 0px rgba(10, 89, 215, 0.4);
    border-radius: 10px;
    display: flex;

    .images {
      background-image: url("@/assets/config/banner.png");
      background-size: 100% 100%;
      width: 350px;
      height: 100%;
    }

    .login-form {
      width: calc(100% - 350px);
      height: 100%;
      background: #ffffff;
      border-radius: 0px 10px 10px 0px;
      position: relative;
      overflow: hidden;

      .login-switch {
        position: absolute;
        right: 0;
        top: 0;
        width: 64px;
        height: 64px;
        background: #ffffffff;
        box-shadow: inset 2px -2px 4px 0 #1c20291a;
        clip-path: polygon(0 0, 100% 0, 100% 100%);
        cursor: pointer;

        .list {
          width: 100%;
          height: 100%;

          img {
            width: 100%;
            height: 100%;
            object-fit: contain;
          }
        }
      }

      .title {
        height: 100px;
        color: #4d6fffff;
        font-size: 22px;
        font-weight: 700;
        font-family: "Microsoft YaHei UI";
        text-align: left;
        display: flex;
        align-items: flex-end;
        justify-content: center;
      }
    }
  }

  %line {
    content: "";
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    display: block;
    width: 60px;
    height: 2px;
    background: linear-gradient(90deg, #d8eafe, #0156b1);
  }

  footer {
    position: absolute;
    left: 50%;
    bottom: 55px;
    transform: translateX(-50%);
    font-size: 12px;
    font-family: Microsoft YaHei;
    font-weight: 400;
    color: #ffffff;
    padding: 0 10px;

    &::before {
      @extend %line;
      left: 100%;
    }

    &::after {
      @extend %line;
      right: 100%;
      transform: translateY(-50%) rotate(180deg);
    }
  }
}
</style>
